using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerWallGrabState : PlayerTouchingWallState
{
    public PlayerWallGrabState(Player player, PlayerMoveData playerData, StateMachine stateMachine, string animBoolName) : base(player, playerData, stateMachine, animBoolName)
    {
    }

    private Vector3 grabPos;

    public override void Enter()
    {
        base.Enter();

        grabPos = player.transform.position;
    }

    public override void LogicUpdate()
    {
        base.LogicUpdate();

        player.transform.position = grabPos;
        player.SetVelocityZero();

        if (yInput == 1)
        {
            stateMachine.ChangeState(player.WallClimbState);
        }
        else if (yInput == -1) 
        {
            stateMachine.ChangeState(player.WallSlideState);
        }
        else if (jumpInput)
        {
            stateMachine.ChangeState(player.WallNegativeJumpState);
        }

        if (!grabInput && xInput == player.FacingDirection) 
        {
            stateMachine.ChangeState(player.WallSlideState);
        }
    }
}
